<script setup>
import { watchEffect } from 'vue'
import { useAuthStore } from '@/stores/useAuthStore'

const store = useAuthStore()

// 页面刷新，vuex中存储的状态依然存在
watchEffect(() => {
  //watchEffect页面一刷新，方法立即被调用
  if (localStorage.token) {
    store.setAuth(true)
    const user = store.getUser
    user.tokenHead = localStorage.getItem('tokenHead')
    user.token = localStorage.getItem('token')
    store.setUser(user)
  }
})
</script>

<template>
  <router-view></router-view>
</template>

<style scoped></style>
